home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / doc / insert.txt < prev    next >
Encoding:
Text File  |  2001-09-26  |  42.4 KB  |  1,027 lines

  1. *insert.txt*    For Vim version 6.0.  Last change: 2001 Sep 16
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7.                         *Insert* *Insert-mode*
  8. Inserting and replacing text                *mode-ins-repl*
  9.  
  10. Most of this file is about Insert and Replace mode.  At the end are a few
  11. commands for inserting text in other ways.
  12.  
  13. An overview of the most often used commands can be found in chapter 24 of the
  14. user manual |usr_24.txt|.
  15.  
  16. 1. Special keys                        |ins-special-keys|
  17. 2. Special special keys                    |ins-special-special|
  18. 3. 'textwidth' and 'wrapmargin' options            |ins-textwidth|
  19. 4. 'expandtab', 'smarttab' and 'softtabstop'  options    |ins-expandtab|
  20. 5. Replace mode                        |Replace-mode|
  21. 6. Virtual replace mode                    |Virtual-replace-mode|
  22. 7. Insert mode completion                |ins-completion|
  23. 8. Insert mode commands                    |inserting|
  24. 9. Ex insert commands                    |inserting-ex|
  25. 10. Inserting a file                    |inserting-file|
  26.  
  27. Also see 'virtualedit', for moving the cursor to positions where there is no
  28. character.  Useful for editing a table.
  29.  
  30. ==============================================================================
  31. 1. Special keys                        *ins-special-keys*
  32.  
  33. In Insert and Replace mode, the following characters have a special meaning;
  34. other characters are inserted directly.  To insert one of these special
  35. characters into the buffer, precede it with CTRL-V.  To insert a <Nul>
  36. character use "CTRL-V CTRL-@" or "CTRL-V 000".  On some systems, you have to
  37. use "CTRL-V 003" to insert a CTRL-C.
  38.  
  39. If you are working in a special language mode when inserting text, see the
  40. 'langmap' option, |'langmap'|, on how to avoid switching this mode on and off
  41. all the time.
  42.  
  43. If you have 'insertmode' set, <Esc> and a few other keys get another meaning.
  44. See |'insertmode'|.
  45.  
  46. char        action    ~
  47. -----------------------------------------------------------------------
  48.                         *i_CTRL-[* *i_<Esc>*
  49. <Esc> or CTRL-[    End insert or Replace mode, go back to Normal mode.  Finish
  50.         abbreviation.
  51.         Note: If your <Esc> key is hard to hit on your keyboard, train
  52.         yourself to use CTRL-[.
  53.                         *i_CTRL-C*
  54. CTRL-C        Quit insert mode, go back to Normal mode.  Do not check for
  55.         abbreviations.
  56.  
  57.                         *i_CTRL-@*
  58. CTRL-@        Insert previously inserted text and stop insert.  {Vi: only
  59.         when typed as first char, only up to 128 chars}
  60.                         *i_CTRL-A*
  61. CTRL-A        Insert previously inserted text.  {not in Vi}
  62.  
  63.                         *i_CTRL-H* *i_<BS>* *i_BS*
  64. <BS> or CTRL-H    Delete the character before the cursor (see |i_backspacing|
  65.         about joining lines).
  66.         See |:fixdel| if your <BS> key does not do what you want.
  67.         {Vi: does not delete autoindents}
  68.                         *i_<Del>* *i_DEL*
  69. <Del>        Delete the character under the cursor.  If the cursor is at
  70.         the end of the line, and the 'backspace' option includes
  71.         "eol", delete the <EOL>; the next line is appended after the
  72.         current one.
  73.         See |:fixdel| if your <Del> key does not do what you want.
  74.         {not in Vi}
  75.                         *i_CTRL-W*
  76. CTRL-W        Delete the word before the cursor (see |i_backspacing| about
  77.         joining lines).  See the section "word motions",
  78.         |word-motions|, for the definition of a word.
  79.                         *i_CTRL-U*
  80. CTRL-U        Delete all entered characters in the current line (see
  81.         |i_backspacing| about joining lines).
  82.  
  83.                         *i_CTRL-I* *i_<Tab>* *i_Tab*
  84. <Tab> or CTRL-I Insert a tab.  If the 'expandtab' option is on, the
  85.         equivalent number of spaces is inserted (use CTRL-V <Tab> to
  86.         avoid the expansion).  See also the 'smarttab' option and
  87.         |ins-expandtab|.
  88.                         *i_CTRL-J* *i_<NL>*
  89. <NL> or CTRL-J    Begin new line.
  90.                         *i_CTRL-M* *i_<CR>*
  91. <CR> or CTRL-M    Begin new line.
  92.                         *i_CTRL-K*
  93. CTRL-K {char1} [char2]
  94.         Enter digraph (see |digraphs|).  When {char1} is a special
  95.         key, the code for that key is inserted in <> form.  For
  96.         example, the string "<S-Space>" can be entered by typing
  97.         <C-K><S-Space> (two keys).  Neither char is considered for
  98.         mapping.  {not in Vi}
  99.  
  100. CTRL-N        Find next keyword (see |i_CTRL-N|).  {not in Vi}
  101. CTRL-P        Find previous keyword (see |i_CTRL-P|).  {not in Vi}
  102.  
  103. CTRL-R {0-9a-z"%#*:.-=}                    *i_CTRL-R*
  104.         Insert the contents of a register.  Between typing CTRL-R and
  105.         the second character, '"' will be displayed to indicate that
  106.         you are expected to enter the name of a register.
  107.         The text is inserted as if you typed it, but mappings and
  108.         abbreviations are not used.  If you have options like
  109.         'textwidth', 'formatoptions', or 'autoindent' set, this will
  110.         influence what will be inserted.  This is different from what
  111.         happens with the "p" command and pasting with the mouse.
  112.         Special registers:
  113.             '"'    the unnamed register, containing the text of
  114.                 the last delete or yank
  115.             '%'    the current file name
  116.             '#'    the alternate file name
  117.             '*'    the clipboard contents
  118.             '/'    the last search pattern
  119.             ':'    the last command-line
  120.             '.'    the last inserted text
  121.             '-'    the last small (less than a line) delete
  122.             '='    the expression register: you are prompted to
  123.                 enter an expression (see |expression|)
  124.         See |registers| about registers.  {not in Vi}
  125.  
  126. CTRL-R CTRL-R {0-9a-z"%#*/:.-=}                *i_CTRL-R_CTRL-R*
  127.         Insert the contents of a register.  Works like using a single
  128.         CTRL-R, but the text is inserted literally, not as if typed.
  129.         This differs when the register contains characters like <BS>.
  130.         Example, where register a contains "ab^Hc": >
  131.     CTRL-R a        results in "ac".
  132.     CTRL-R CTRL-R a        results in "ab^Hc".
  133. <        Options 'textwidth', 'formatoptions', etc. still apply.  If
  134.         you also want to avoid these, use "<C-R><C-O>r", see below.
  135.         The '.' register (last inserted text) is still inserted as
  136.         typed.  {not in Vi}
  137.  
  138. CTRL-R CTRL-O {0-9a-z"%#*/:.-=}                *i_CTRL-R_CTRL-O*
  139.         Insert the contents of a register literally and don't
  140.         auto-indent.  Does the same as pasting with the mouse
  141.         |<MiddleMouse>|.
  142.         Does not replace characters!
  143.         The '.' register (last inserted text) is still inserted as
  144.         typed.  {not in Vi}
  145.  
  146. CTRL-R CTRL-P {0-9a-z"%#*/:.-=}                *i_CTRL-R_CTRL-P*
  147.         Insert the contents of a register literally and fix the
  148.         indent, like |[<MiddleMouse>|.
  149.         Does not replace characters!
  150.         The '.' register (last inserted text) is still inserted as
  151.         typed.  {not in Vi}
  152.  
  153.                         *i_CTRL-T*
  154. CTRL-T        Insert one shiftwidth of indent at the start of the current
  155.         line.  The indent is always rounded to a 'shiftwidth' (this is
  156.         vi compatible).  {Vi: only when in indent}
  157.                         *i_CTRL-D*
  158. CTRL-D        Delete one shiftwidth of indent at the start of the current
  159.         line.  The indent is always rounded to a 'shiftwidth' (this is
  160.         vi compatible).  {Vi: CTRL-D works only when used after
  161.         autoindent}
  162.                         *i_0_CTRL-D*
  163. 0 CTRL-D    Delete all indent in the current line.  {Vi: CTRL-D works
  164.         only when used after autoindent}
  165.                         *i_^_CTRL-D*
  166. ^ CTRL-D    Delete all indent in the current line.  The indent is
  167.         restored in the next line.  This is useful when inserting a
  168.         label.  {Vi: CTRL-D works only when used after autoindent}
  169.  
  170.                         *i_CTRL-V*
  171. CTRL-V        Insert next non-digit literally.  For special keys, the
  172.         terminal code is inserted.  It's also possible to enter the
  173.         decimal, octal or hexadecimal value of a character
  174.         |i_CTRL-V_digit|.
  175.         The characters typed right after CTRL-V are not considered for
  176.         mapping.  {Vi: no decimal byte entry}
  177.         Note: Under Windows CTRL-V is often mapped to paste text.
  178.         Then use CTRL-Q instead.
  179.  
  180.                         *i_CTRL-Q*
  181. CTRL-Q        Same as CTRL-V.
  182.         Note: Some terminal connections may eat CTRL-Q.
  183.  
  184. CTRL-X        Enter CTRL-X mode.  This is a sub-mode where commands can
  185.         be given to complete words or scroll the window. See
  186.         |i_CTRL-X| and |ins-completion|. {not in Vi}
  187.  
  188.                         *i_CTRL-E*
  189. CTRL-E        Insert the character which is below the cursor.  {not in Vi}
  190.                         *i_CTRL-Y*
  191. CTRL-Y        Insert the character which is above the cursor.  {not in Vi}
  192.         Note that for CTRL-E and CTRL-Y 'textwidth' is not used, to be
  193.         able to copy characters from a long line.
  194.  
  195.                         *i_CTRL-_*
  196. CTRL-_        Switch between languages, as follows:
  197.         -  When in a rightleft window, revins and nohkmap are toggled,
  198.            since English will likely be inserted in this case.
  199.         -  When in a norightleft window, revins and hkmap are toggled,
  200.            since Hebrew will likely be inserted in this case.
  201.  
  202.         CTRL-_ moves the cursor to the end of the typed text.
  203.  
  204.         This command is only available when the 'allowrevins' option
  205.         is set.
  206.         Please refer to |rileft.txt| for more information about
  207.         right-to-left mode.
  208.         {not in Vi}
  209.         Only if compiled with the |+rightleft| feature (which is not
  210.         the default).
  211.                         *i_CTRL-^*
  212. CTRL-^        Toggle the use of typing language characters.
  213.         When language |:lmap| mappings are defined:
  214.         - If 'iminsert' is 1 (langmap mappings used) it becomes 0 (no
  215.           langmap mappings used).
  216.         - If 'iminsert' has another value it becomes 1, thus langmap
  217.           mappings are enabled.
  218.         When no language mappings are defined:
  219.         - If 'iminsert' is 2 (Input Method used) it becomes 0 (no
  220.           Input Method used).
  221.         - If 'iminsert' has another value it becomes 2, thus the Input
  222.           Method is enabled.
  223.         When set to 1, the value of the "b:keymap_name" variable, the
  224.         'keymap' option or "<lang>" appears in the status line.
  225.         The language mappings are normally used to type characters
  226.         that are different from what the keyboard produces.  The
  227.         'keymap' option can be used to install a whole number of them.
  228.         {not in Vi}
  229.  
  230.                         *i_CTRL-]*
  231. CTRL-]        Trigger abbreviation, without inserting a character.  {not in
  232.         Vi}
  233.  
  234.                         *i_<Insert>*
  235. <Insert>    Toggle between Insert and Replace mode.  {not in Vi}
  236. -----------------------------------------------------------------------
  237.  
  238.                         *i_backspacing*
  239. The effect of the <BS>, CTRL-W, and CTRL-U depend on the 'backspace' option
  240. (unless 'revins' is set).  This is a comma separated list of items:
  241.  
  242. item        action ~
  243. indent        allow backspacing over autoindent
  244. eol        allow backspacing over end-of-line (join lines)
  245. start        allow backspacing over the start position of insert; CTRL-W and
  246.         CTRL-U stop once at the start position
  247.  
  248. When 'backspace' is empty, Vi compatible backspacing is used.  You cannot
  249. backspace over autoindent, before column 1 or before where insert started.
  250.  
  251. For backwards compatibility the values "0", "1" and "2" are also allowed, see
  252. |'backspace'|.
  253.  
  254. If the 'backspace' option does contain "eol" and the cursor is in column 1
  255. when one of the three keys is used, the current line is joined with the
  256. previous line.  This effectively deletes the <EOL> in front of the cursor.
  257. {Vi: does not cross lines, does not delete past start position of insert}
  258.  
  259.                         *i_CTRL-V_digit*
  260. With CTRL-V the decimal, octal or hexadecimal value of a character can be
  261. entered directly.  This way you can enter any character, except a line break
  262. (<NL>, value 10).  There are five ways to enter the character value:
  263.  
  264. first char    mode         max nr of chars   max value ~
  265. (none)        decimal           3        255
  266. o or O        octal           3        255
  267. x or X        hexadecimal       2        ff     (255)
  268. u        hexadecimal       4        ffff     (65535)
  269. U        hexadecimal       8        7fffffff (2147483647)
  270.  
  271. Normally you would type the maximum number of characters.  Thus to enter a
  272. space (value 32) you would type <C-V>032.  You can omit the leading zero, in
  273. which case the character typed after the number must be a non-digit.  This
  274. happens for the other modes as well: As soon as you type a character that is
  275. invalid for the mode, the value before it will be used and the "invalid"
  276. character is dealt with in the normal way.
  277.  
  278. If you enter a value of 10, it will end up in the file as a 0.  The 10 is a
  279. <NL>, which is used internally to represent the <Nul> character.  When writing
  280. the buffer to a file, the <NL> character is translated into <Nul>.  The <NL>
  281. character is written at the end of each line.  Thus if you want to insert a
  282. <NL> character in a file you will have to make a line break.
  283.  
  284.                         *i_CTRL-X* *insert_expand*
  285. CTRL-X enters a sub-mode where several commands can be used.  Most of these
  286. commands do keyword completion; see |ins-completion|.  These are not available
  287. when Vim was compiled without the |+insert_expand| feature.
  288.  
  289. Two commands can be used to scroll the window up or down, without exiting
  290. insert mode:
  291.  
  292.                         *i_CTRL-X_CTRL-E*
  293. CTRL-X CTRL-E        scroll window one line up.
  294.  
  295.                         *i_CTRL-X_CTRL-Y*
  296. CTRL-X CTRL-Y        scroll window one line down.
  297.  
  298. After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by
  299. one line unless that would cause the cursor to move from its current position
  300. in the file.  As soon as another key is pressed, CTRL-X mode is exited and
  301. that key is interpreted as in Insert mode.
  302.  
  303.  
  304. ==============================================================================
  305. 2. Special special keys                *ins-special-special*
  306.  
  307. The following keys are special.  They stop the current insert, do something,
  308. and then restart insertion.  This means you can do something without getting
  309. out of Insert mode.  This is very handy if you prefer to use the Insert mode
  310. all the time, just like editors that don't have a separate Normal mode.  You
  311. may also want to set the 'backspace' option to "indent,eol,start" and set the
  312. 'insertmode' option.  You can use CTRL-O if you want to map a function key to
  313. a command.
  314.  
  315. The changes (inserted or deleted characters) before and after these keys can
  316. be undone separately.  Only the last change can be redone and always behaves
  317. like an "i" command.
  318.  
  319. char        action    ~
  320. -----------------------------------------------------------------------
  321. <Up>        cursor one line up                 *i_<Up>*
  322. <Down>        cursor one line down                 *i_<Down>*
  323. CTRL-G <Up>    cursor one line up, insert start column         *i_CTRL-G_<Up>*
  324. CTRL-G k    cursor one line up, insert start column         *i_CTRL-G_k*
  325. CTRL-G CTRL-K    cursor one line up, insert start column         *i_CTRL-G_CTRL-K*
  326. CTRL-G <Down>    cursor one line down, insert start column    *i_CTRL-G_<Down>*
  327. CTRL-G j    cursor one line down, insert start column    *i_CTRL-G_j*
  328. CTRL-G CTRL-J    cursor one line down, insert start column    *i_CTRL-G_CTRL-J*
  329. <Left>        cursor one character left             *i_<Left>*
  330. <Right>        cursor one character right             *i_<Right>*
  331. <S-Left>    cursor one word back (like "b" command)         *i_<S-Left>*
  332. <C-Left>    cursor one word back (like "b" command)         *i_<C-Left>*
  333. <S-Right>    cursor one word forward (like "w" command)   *i_<S-Right>*
  334. <C-Right>    cursor one word forward (like "w" command)   *i_<C-Right>*
  335. <Home>        cursor to first char in the line         *i_<Home>*
  336. <End>        cursor to after last char in the line         *i_<End>*
  337. <C-Home>    cursor to first char in the file         *i_<C-Home>*
  338. <C-End>        cursor to after last char in the file         *i_<C-End>*
  339. <LeftMouse>    cursor to position of mouse click         *i_<LeftMouse>*
  340. <S-Up>        move window one page up                 *i_<S-Up>*
  341. <PageUp>    move window one page up                 *i_<PageUp>*
  342. <S-Down>    move window one page down             *i_<S-Down>*
  343. <PageDown>    move window one page down             *i_<PageDown>*
  344. <MouseDown>    scroll three lines down                 *i_<MouseDown>*
  345. <S-MouseDown>    scroll a full page down                 *i_<S-MouseDown>*
  346. <MouseUp>    scroll three lines up                 *i_<MouseUp>*
  347. <S-MouseUp>    scroll a full page up                 *i_<S-MouseUp>*
  348. CTRL-O        execute one command, return to Insert mode   *i_CTRL-O*
  349. -----------------------------------------------------------------------
  350.  
  351. Note: If the cursor keys take you out of Insert mode, check the 'noesckeys'
  352. option.
  353.  
  354. The CTRL-O command sometimes has one side effect: If the cursor was beyond the
  355. end of the line, it will be put on the last character in the line.
  356. The shifted cursor keys are not available on all terminals.
  357.  
  358. When the 'whichwrap' option is set appropriately, the <Left> and <Right>
  359. keys on the first/last character in the line make the cursor wrap to the
  360. previous/next line.
  361.  
  362. The CTRL-G j and CTRL-G k commands can be used to insert text in front of a
  363. column.  Example: >
  364.    int i;
  365.    int j;
  366. Position the cursor on the first "int", type "istatic<C-G>j       ".  The
  367. result is: >
  368.    static int i;
  369.       int j;
  370. When inserting the same text in front of the column in every line, use the
  371. Visual blockwise command "I" |v_b_I|.
  372.  
  373. ==============================================================================
  374. 3. 'textwidth' and 'wrapmargin' options            *ins-textwidth*
  375.  
  376. The 'textwidth' option can be used to automatically break a line before it
  377. gets too long.  Set the 'textwidth' option to the desired maximum line
  378. length.  If you then type more characters (not spaces or tabs), the
  379. last word will be put on a new line (unless it is the only word on the
  380. line).  If you set 'textwidth' to 0, this feature is disabled.
  381.  
  382. The 'wrapmargin' option does almost the same.  The difference is that
  383. 'textwidth' has a fixed width while 'wrapmargin' depends on the width of the
  384. screen.  When using 'wrapmargin' this is equal to using 'textwidth' with a
  385. value equal to (columns - 'wrapmargin'), where columns is the width of the
  386. screen.
  387.  
  388. When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.
  389.  
  390. If you don't really want to break the line, but view the line wrapped at a
  391. convenient place, see the 'linebreak' option.
  392.  
  393. The line is only broken automatically when using insert mode, or when
  394. appending to a line.  When in replace mode and the line length is not
  395. changed, the line will not be broken.
  396.  
  397. Long lines are broken if you enter a non-white character after the margin.
  398. The situations where a line will be broken can be restricted by adding
  399. characters to the 'formatoptions' option:
  400. "l"  Only break a line if it was not longer than 'textwidth' when the insert
  401.      started.
  402. "v"  Only break at a white character that has been entered during the
  403.      current insert command.  This is mostly Vi-compatible.
  404. "lv" Only break if the line was not longer than 'textwidth' when the insert
  405.      started and only at a white character that has been entered during the
  406.      current insert command.  Only differs from "l" when entering non-white
  407.      characters while crossing the 'textwidth' boundary.
  408.  
  409. If you want to format a block of text, you can use the "gq" operator.  Type
  410. "gq" and a movement command to move the cursor to the end of the block.  In
  411. many cases, the command "gq}" will do what you want (format until the end of
  412. paragraph).  Alternatively, you can use "gqap", which will format the whole
  413. paragraph, no matter where the cursor currently is.  Or you can use Visual
  414. mode: hit "v", move to the end of the block, and type "gq".  See also |gq|.
  415.  
  416. ==============================================================================
  417. 4. 'expandtab', 'smarttab' and 'softtabstop' options    *ins-expandtab*
  418.  
  419. If the 'expandtab' option is on, spaces will be used to fill the amount of
  420. whitespace of the tab.  If you want to enter a real <Tab>, type CTRL-V first.
  421. The 'expandtab' option is off by default.  Note that in Replace mode, a single
  422. character is replaced with several spaces.  The result of this is that the
  423. number of characters in the line increases.  Backspacing will delete one
  424. space at a time.  The original character will be put back for only one space
  425. that you backspace over (the last one).  {Vi does not have the 'expandtab'
  426. option}
  427.  
  428.                             *ins-smarttab*
  429. When the 'smarttab' option is on, a <Tab> inserts 'shiftwidth' positions at
  430. the beginning of a line and 'tabstop' positions in other places.  This means
  431. that often spaces instead of a <Tab> character are inserted.  When 'smarttab
  432. is off, a <Tab> always inserts 'tabstop' positions, and 'shiftwidth' is only
  433. used for ">>" and the like.  {not in Vi}
  434.  
  435.                             *ins-softtabstop*
  436. When the 'softtabstop' option is non-zero, a <Tab> inserts 'softtabstop'
  437. positions, and a <BS> used to delete white space, will delete 'softtabstop'
  438. positions.  This feels like 'tabstop' was set to 'softtabstop', but a real
  439. <Tab> character still takes 'tabstop' positions, so your file will still look
  440. correct when used by other applications.
  441.  
  442. If 'softtabstop' is non-zero, a <BS> will try to delete as much white space to
  443. move to the previous 'softtabstop' position, except when the previously
  444. inserted character is a space, then it will only delete the character before
  445. the cursor.  Otherwise you cannot always delete a single character before the
  446. cursor.  You will have to delete 'softtabstop' characters first, and then type
  447. extra spaces to get where you want to be.
  448.  
  449.  
  450. ==============================================================================
  451. 5. Replace mode                *Replace* *Replace-mode* *mode-replace*
  452.  
  453. Enter Replace mode with the "R" command in normal mode.
  454.  
  455. In Replace mode, one character in the line is deleted for every character you
  456. type.  If there is no character to delete (at the end of the line), the
  457. typed character is appended (as in Insert mode).  Thus the number of
  458. characters in a line stays the same until you get to the end of the line.
  459. If a <NL> is typed, a line break is inserted and no character is deleted.
  460.  
  461. Be careful with <Tab> characters.  If you type a normal printing character in
  462. its place, the number of characters is still the same, but the number of
  463. columns will become smaller.
  464.  
  465. If you delete characters in Replace mode (with <BS>, CTRL-W, or CTRL-U), what
  466. happens is that you delete the changes.  The characters that were replaced
  467. are restored.  If you had typed past the existing text, the characters you
  468. added are deleted.  This is effectively a character-at-a-time undo.
  469.  
  470. If the 'expandtab' option is on, a <Tab> will replace one character with
  471. several spaces.  The result of this is that the number of characters in the
  472. line increases.  Backspacing will delete one space at a time.  The original
  473. character will be put back for only one space that you backspace over (the
  474. last one).  {Vi does not have the 'expandtab' option}
  475.  
  476. ==============================================================================
  477. 6. Virtual replace mode        *vreplace-mode* *Virtual-replace-mode*
  478.  
  479. Enter Virtual replace mode with the "gR" command in normal mode.
  480. {not available when compiled without the +vreplace feature}
  481. {Vi does not have Virtual replace mode}
  482.  
  483. Virtual replace mode is similar to Replace mode, but instead of replacing
  484. actual characters in the file, you are replacing screen real estate, so that
  485. characters further on in the file never appear to move.
  486.  
  487. So if you type a <Tab> it may replace several normal characters, and if you
  488. type a letter on top of a <Tab> it may not replace anything at all, since the
  489. <Tab> will still line up to the same place as before.
  490.  
  491. Typing a <NL> still doesn't cause characters later in the file to appear to
  492. move.  The rest of the current line will be replaced by the <NL> (that is,
  493. they are deleted), and replacing continues on the next line.  A new line is
  494. NOT inserted unless you go past the end of the file.
  495.  
  496. Interesting effects are seen when using CTRL-T and CTRL-D.  The characters
  497. before the cursor are shifted sideways as normal, but characters later in the
  498. line still remain still.  CTRL-T will hide some of the old line under the
  499. shifted characters, but CTRL-D will reveal them again.
  500.  
  501. As with Replace mode, using <BS> etc will bring back the characters that were
  502. replaced.  This still works in conjunction with 'smartindent', CTRL-T and
  503. CTRL-D, 'expandtab', 'smarttab', 'softtabstop', etc.
  504.  
  505. In 'list' mode, Virtual replace mode acts as if it was not in 'list' mode,
  506. unless "L" is in 'cpoptions'.
  507.  
  508. Note that the only times characters beyond the cursor should appear to move
  509. are in 'list' mode, and occasionally when 'wrap' is set (and the line changes
  510. length to become shorter or wider than the width of the screen), or
  511. momentarily when typing over a CTRL character.  A CTRL character takes up two
  512. screen spaces.  When replacing it with two normal characters, the first will
  513. be inserted and the second will replace the CTRL character.
  514.  
  515. This mode is very useful for editing <Tab> separated columns in tables, for
  516. entering new data while keeping all the columns aligned.
  517.  
  518. ==============================================================================
  519. 7. Insert mode completion                *ins-completion*
  520.  
  521. In Insert and Replace modes, there are several commands to complete part of a
  522. keyword or line that has been typed.  This is useful if you are using
  523. complicated keywords (e.g., function names with capitals and underscores).
  524.  
  525. These commands are not available when the |+insert_expand| feature was
  526. disabled at compile time.
  527.  
  528. Completion can be done for:
  529.  
  530. 1. Whole lines                        |i_CTRL-X_CTRL-L|
  531. 2. keywords in the current file                |i_CTRL-X_CTRL-N|
  532. 3. keywords in 'dictionary'                |i_CTRL-X_CTRL-K|
  533. 4. keywords in 'thesaurus', thesaurus-style        |i_CTRL-X_CTRL-T|
  534. 5. keywords in the current and included files        |i_CTRL-X_CTRL-I|
  535. 6. tags                            |i_CTRL-X_CTRL-]|
  536. 7. file names                        |i_CTRL-X_CTRL-F|
  537. 8. definitions or macros                |i_CTRL-X_CTRL-D|
  538. 9. Vim command-line                    |i_CTRL-X_CTRL-V|
  539. 10. keywords in 'complete'                |i_CTRL-N|
  540.  
  541. All these (except 2) are done in CTRL-X mode.  This is a sub-mode of Insert
  542. and Replace modes.  You enter CTRL-X mode by typing CTRL-X and one of the
  543. CTRL-X commands.  You exit CTRL-X mode by typing a key that is not a valid
  544. CTRL-X mode command.  Valid keys are the CTRL-X command itself, CTRL-N (next),
  545. and CTRL-P (previous).
  546.  
  547. Also see the 'infercase' option if you want to adjust the case of the match.
  548.  
  549. Note: The keys that are valid in CTRL-X mode are not mapped.  This allows for
  550. ":map ^F ^X^F" to work (where ^F is CTRL-F and ^X is CTRL-X).  The key that
  551. ends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped.
  552.  
  553. The following mappings are suggested to make typing the completion commands
  554. a bit easier (although they will hide other commands):
  555.     :inoremap ^] ^X^]
  556.     :inoremap ^F ^X^F
  557.     :inoremap ^D ^X^D
  558.     :inoremap ^L ^X^L
  559.  
  560. As a special case, typing CTRL-R to perform register insertion (see
  561. |i_CTRL-R|) will not exit CTRL-X mode.  This is primarily to allow the use of
  562. the '=' register to call some function to determine the next operation.  If
  563. the contents of the register (or result of the '=' register evaluation) are
  564. not valid CTRL-X mode keys, then CTRL-X mode will be exited as if those keys
  565. had been typed.
  566.  
  567. For example, the following will map <Tab> to either actually insert a <Tab> if
  568. the current line is currently only whitespace, or start/continue a CTRL-N
  569. completion operation: >
  570.  
  571.     function! CleverTab()
  572.        if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
  573.           return "\<Tab>"
  574.        else
  575.           return "\<C-N>"
  576.     endfunction
  577.     inoremap <Tab> <C-R>=CleverTab()<CR>
  578.  
  579.  
  580.  
  581. Completing whole lines                    *compl-whole-line*
  582.  
  583.                             *i_CTRL-X_CTRL-L*
  584. CTRL-X CTRL-L        Search backwards for a line that starts with the
  585.             same characters as in the current line before the
  586.             cursor.  Indent is ignored.  The found line is
  587.             inserted in front of the cursor.
  588.             The 'complete' option is used to decide in which
  589.             buffers a match is searched for.  But only loaded
  590.             buffers are used.
  591.     CTRL-L    or
  592.     CTRL-P        Search backwards for next matching line.  This line
  593.             replaces the previous matching line.
  594.  
  595.     CTRL-N        Search forward for next matching line.  This line
  596.             replaces the previous matching line.
  597.  
  598.     CTRL-X CTRL-L    After expanding a line you can additionally get the
  599.             line next to it by typing CTRL-X CTRL-L again, unless
  600.             a double CTRL-X is used.
  601.  
  602. Completing keywords in current file            *compl-current*
  603.  
  604.                             *i_CTRL-X_CTRL-P*
  605.                             *i_CTRL-X_CTRL-N*
  606. CTRL-X CTRL-N        Search forwards for words that start with the keyword
  607.             in front of the cursor.  The found keyword is inserted
  608.             in front of the cursor.
  609.  
  610. CTRL-X CTRL-P        Search backwards for words that start with the keyword
  611.             in front of the cursor.  The found keyword is inserted
  612.             in front of the cursor.
  613.  
  614.     CTRL-N        Search forward for next matching keyword.  This
  615.             keyword replaces the previous matching keyword.
  616.  
  617.     CTRL-P        Search backwards for next matching keyword.  This
  618.             keyword replaces the previous matching keyword.
  619.  
  620.     CTRL-X CTRL-N or
  621.     CTRL-X CTRL-P    Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
  622.             copy the words following the previous expansion in
  623.             other contexts unless a double CTRL-X is used.
  624.  
  625. If there is a keyword in front of the cursor (a name made out of alphabetic
  626. characters and characters in 'iskeyword'), it is used as the search pattern,
  627. with "\<" prepended (meaning: start of a word).  Otherwise "\<\k\k" is used
  628. as search pattern (start of any keyword of at least two characters).
  629.  
  630. In Replace mode, the number of characters that are replaced depends on the
  631. length of the matched string.  This works like typing the characters of the
  632. matched string in Replace mode.
  633.  
  634. If there is not a valid keyword character before the cursor, any keyword of
  635. at least two characters is matched.
  636.     e.g., to get:
  637.         printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
  638.     just type:
  639.         printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
  640.  
  641. Multiple repeats of the same completion are skipped; thus a different match
  642. will be inserted at each CTRL-N and CTRL-P (unless there is only one
  643. matching keyword).
  644.  
  645. Single character matches are never included, as they usually just get in
  646. the way of what you were really after.
  647.     e.g., to get:
  648.         printf("name = %s\n", name);
  649.     just type:
  650.         printf("name = %s\n", n^P);
  651.     or even:
  652.         printf("name = %s\n", ^P);
  653. The 'n' in '\n' is skipped.
  654.  
  655. After expanding a word, you can use CTRL-X CTRL-P or CTRL-X CTRL-N to get the
  656. word following the expansion in other contexts.  These sequences search for
  657. the text just expanded and further expand by getting an extra word.  This is
  658. useful if you need to repeat a sequence of complicated words.  Although CTRL-P
  659. and CTRL-N look just for strings of at least two characters, CTRL-X CTRL-P and
  660. CTRL-X CTRL-N can be used to expand words of just one character.
  661.     e.g., to get:
  662.         México
  663.     you can type:
  664.         M^N^P^X^P^X^P
  665. CTRL-N starts the expansion and then CTRL-P takes back the single character
  666. "M", the next two CTRL-X CTRL-P's get the words "é" and ";xico".
  667.  
  668. If the previous expansion was split, because it got longer than 'textwidth',
  669. then just the text in the current line will be used.
  670.  
  671. If the match found is at the end of a line, then the first word in the next
  672. line will be inserted and the message "word from next line" displayed, if
  673. this word is accepted the next CTRL-X CTRL-P or CTRL-X CTRL-N will search
  674. for those lines starting with this word.
  675.  
  676.  
  677. Completing keywords in 'dictionary'            *compl-dictionary*
  678.  
  679.                             *i_CTRL-X_CTRL-K*
  680. CTRL-X CTRL-K        Search the files given with the 'dictionary' option
  681.             for words that start with the keyword in front of the
  682.             cursor.  This is like CTRL-N, but only the dictionary
  683.             files are searched, not the current file.  The found
  684.             keyword is inserted in front of the cursor.  This
  685.             could potentially be pretty slow, since all matches
  686.             are found before the first match is used.  By default,
  687.             the 'dictionary' option is empty.
  688.             For suggestions where to find a list of words, see the
  689.             'dictionary' option.
  690.  
  691.     CTRL-K    or
  692.     CTRL-N        Search forward for next matching keyword.  This
  693.             keyword replaces the previous matching keyword.
  694.  
  695.     CTRL-P        Search backwards for next matching keyword.  This
  696.             keyword replaces the previous matching keyword.
  697.  
  698.                             *i_CTRL-X_CTRL-T*
  699. CTRL-X CTRL-T        Works as CTRL-X CTRL-K, but in a special way. It uses
  700.             the 'thesaurus' option instead of 'dictionary'.  If a
  701.             match is found in the thesaurus file, all the
  702.             remaining words on the same line are included as
  703.             matches, even though they don't complete the word.
  704.             Thus a word can be completely replaced.
  705.  
  706.             For an example, imagine the 'thesaurus' file has a
  707.             line like this: >
  708.                 angry furious mad enraged
  709. <            Placing the cursor after the letters "ang" and typing
  710.             CTRL-X CTRL-T would complete the word "angry";
  711.             subsequent presses would change the word to "furious",
  712.             "mad" etc.
  713.             Other uses include translation between two languages,
  714.             or grouping API functions by keyword.
  715.  
  716.     CTRL-T    or
  717.     CTRL-N        Search forward for next matching keyword.  This
  718.             keyword replaces the previous matching keyword.
  719.  
  720.     CTRL-P        Search backwards for next matching keyword.  This
  721.             keyword replaces the previous matching keyword.
  722.  
  723.  
  724. Completing keywords in the current and included files    *compl-keyword*
  725.  
  726. The 'include' option is used to specify a line that contains an include file
  727. name.  The 'path' option is used to search for include files.
  728.  
  729.                             *i_CTRL-X_CTRL-I*
  730. CTRL-X CTRL-I        Search for the first keyword in the current and
  731.             included files that starts with the same characters
  732.             as those before the cursor.  The matched keyword is
  733.             inserted in front of the cursor.
  734.  
  735.     CTRL-N        Search forwards for next matching keyword.  This
  736.             keyword replaces the previous matching keyword.
  737.             Note: CTRL-I is the same as <Tab>, which is likely to
  738.             be typed after a successful completion, therefore
  739.             CTRL-I is not used for searching for the next match.
  740.  
  741.     CTRL-P        Search backward for previous matching keyword.  This
  742.             keyword replaces the previous matching keyword.
  743.  
  744.     CTRL-X CTRL-I    Further use of CTRL-X CTRL-I will copy the words
  745.             following the previous expansion in other contexts
  746.             unless a double CTRL-X is used.
  747.  
  748. Completing tags                        *compl-tag*
  749.                             *i_CTRL-X_CTRL-]*
  750. CTRL-X CTRL-]        Search for the first tag that starts with the same
  751.             characters as before the cursor.  The matching tag is
  752.             inserted in front of the cursor.  Alphabetic
  753.             characters and characters in 'iskeyword' are used
  754.             to decide which characters are included in the tag
  755.             name (same as for a keyword).  See also |CTRL-]|.
  756.             The 'showfulltag' option can be used to add context
  757.             from around the tag definition.
  758.     CTRL-]    or
  759.     CTRL-N        Search forwards for next matching tag.  This tag
  760.             replaces the previous matching tag.
  761.  
  762.     CTRL-P        Search backward for previous matching tag.  This tag
  763.             replaces the previous matching tag.
  764.  
  765.  
  766. Completing file names                    *compl-filename*
  767.                             *i_CTRL-X_CTRL-F*
  768. CTRL-X CTRL-F        Search for the first file name that starts with the
  769.             same characters as before the cursor.  The matching
  770.             file name is inserted in front of the cursor.
  771.             Alphabetic characters and characters in 'isfname'
  772.             are used to decide which characters are included in
  773.             the file name.  Note: the 'path' option is not used
  774.             here (yet).
  775.     CTRL-F    or
  776.     CTRL-N        Search forwards for next matching file name.  This
  777.             file name replaces the previous matching file name.
  778.  
  779.     CTRL-P        Search backward for previous matching file name.
  780.             This file name replaces the previous matching file
  781.             name.
  782.  
  783.  
  784. Completing definitions or macros            *compl-define*
  785.  
  786. The 'define' option is used to specify a line that contains a definition.
  787. The 'include' option is used to specify a line that contains an include file
  788. name.  The 'path' option is used to search for include files.
  789.  
  790.                             *i_CTRL-X_CTRL-D*
  791. CTRL-X CTRL-D        Search in the current and included files for the
  792.             first definition (or macro) name that starts with
  793.             the same characters as before the cursor.  The found
  794.             definition name is inserted in front of the cursor.
  795.     CTRL-D    or
  796.     CTRL-N        Search forwards for next matching macro name.  This
  797.             macro name replaces the previous matching macro
  798.             name.
  799.  
  800.     CTRL-P        Search backward for previous matching macro name.
  801.             This macro name replaces the previous matching macro
  802.             name.
  803.  
  804.     CTRL-X CTRL-D    Further use of CTRL-X CTRL-D will copy the words
  805.             following the previous expansion in other contexts
  806.             unless a double CTRL-X is used.
  807.  
  808.  
  809. Completing Vim commands                    *compl-vim*
  810.  
  811. Completion is context-sensitive.  It works like on the Command-line.  It
  812. completes an Ex command as well as its arguments.
  813.  
  814.                             *i_CTRL-X_CTRL-V*
  815. CTRL-X CTRL-V        Guess what kind of item is in front of the cursor and
  816.             find the first match for it.
  817.     CTRL-V    or
  818.     CTRL-N        Search forwards for next match.  This match replaces
  819.             the previous one.
  820.  
  821.     CTRL-P        Search backward for previous match.  This match
  822.             replaces the previous one.
  823.  
  824.     CTRL-X CTRL-V    Further use of CTRL-X CTRL-V will do the same as
  825.             CTRL-V.  This allows mapping a key to do Vim command
  826.             completion, for example: >
  827.                 :imap <Tab> <C-X><C-V>
  828.  
  829. Completing keywords from different sources        *compl-generic*
  830.  
  831.                             *i_CTRL-N*
  832. CTRL-N            Search backwards in the places given with the
  833.             'complete' option for words that start with the
  834.             keyword in front of the cursor.  The found keyword is
  835.             inserted in front of the cursor.
  836.  
  837.                             *i_CTRL-P*
  838. CTRL-P            Search forwards in the places given with the
  839.             'complete' option for words that start with the
  840.             keyword in front of the cursor.  The found keyword is
  841.             inserted in front of the cursor.
  842.  
  843.     CTRL-N        Search forward for next matching keyword.  This
  844.             keyword replaces the previous matching keyword.
  845.  
  846.     CTRL-P        Search backwards for next matching keyword.  This
  847.             keyword replaces the previous matching keyword.
  848.  
  849.     CTRL-X CTRL-N or
  850.     CTRL-X CTRL-P    Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
  851.             copy the words following the previous expansion in
  852.             other contexts unless a double CTRL-X is used.
  853.  
  854. ==============================================================================
  855. 8. Insert mode commands                    *inserting*
  856.  
  857. The following commands can be used to insert new text into the buffer.  They
  858. can all be undone and repeated with the "." command.
  859.  
  860.                             *a*
  861. a            Append text after the cursor [count] times.
  862.  
  863.                             *A*
  864. A            Append text at the end of the line [count] times.
  865.  
  866. <insert>    or                *i* *insert* *<Insert>*
  867. i            Insert text before the cursor [count] times.
  868.  
  869.                             *I*
  870. I            Insert text before the first non-blank in the line
  871.             [count] times.
  872.  
  873.                             *gI*
  874. gI            Insert text in column 1 [count] times.  {not in Vi}
  875.  
  876.                             *gi*
  877. gi            Insert text in the same position as where Insert mode
  878.             was stopped last time in the current buffer.
  879.             This uses the |'^| mark.  It's different from "`^i"
  880.             when the mark is past the end of the line.
  881.             The position is corrected for inserted/deleted lines,
  882.             but NOT for inserted/deleted characters.
  883.             {not in Vi}
  884.  
  885.                             *o*
  886. o            Begin a new line below the cursor and insert text,
  887.             repeat [count] times.  {Vi: blank [count] screen
  888.             lines}
  889.  
  890.                             *O*
  891. O            Begin a new line above the cursor and insert text,
  892.             repeat [count] times.  {Vi: blank [count] screen
  893.             lines}
  894.  
  895. These commands are used to start inserting text.  You can end insert mode with
  896. <Esc>.  See |mode-ins-repl| for the other special characters in Insert mode.
  897. The effect of [count] takes place after Insert mode is exited.
  898.  
  899. When 'autoindent' is on, the indent for a new line is obtained from the
  900. previous line.  When 'smartindent' or 'cindent' is on, the indent for a line
  901. is automatically adjusted for C programs.
  902.  
  903. 'textwidth' can be set to the maximum width for a line.  When a line becomes
  904. too long when appending characters a line break is automatically inserted.
  905.  
  906.  
  907. ==============================================================================
  908. 9. Ex insert commands                    *inserting-ex*
  909.  
  910.                             *:a* *:append*
  911. :{range}a[ppend]    Insert several lines of text below the specified
  912.             line.  If the {range} is missing, the text will be
  913.             inserted after the current line.
  914.  
  915.                             *:i* *:in* *:insert*
  916. :{range}i[nsert]    Insert several lines of text above the specified
  917.             line.  If the {range} is missing, the text will be
  918.             inserted before the current line.
  919.  
  920. These two commands will keep on asking for lines, until you type a line
  921. containing only a ".".  Watch out for lines starting with a backslash, see
  922. |line-continuation|.
  923.  
  924.                             *:start* *:startinsert*
  925. :star[tinsert][!]    Start Insert mode just after executing this command.
  926.             Works like typing "i" in Normal mode.  When the ! is
  927.             included it works like "A", append to the line.
  928.             Otherwise insertion starts at the cursor position.
  929.             Note that when using this command in a function or
  930.             script, the insertion only starts after the function
  931.             or script is finished.
  932.             {not in Vi}
  933.             {not available when compiled without the +ex_extra
  934.             feature}
  935.  
  936. ==============================================================================
  937. 10. Inserting a file                    *inserting-file*
  938.  
  939.                             *:r* *:re* *:read*
  940. :r[ead] [name]        Insert the file [name] (default: current file) below
  941.             the cursor.
  942.  
  943. :{range}r[ead] [name]    Insert the file [name] (default: current file) below
  944.             the specified line.
  945.  
  946.                             *:r!* *:read!*
  947. :r[ead] !{cmd}        Execute {cmd} and insert its standard output below
  948.             the cursor.  A temporary file is used to store the
  949.             output of the command which is then read into the
  950.             buffer.  'shellredir' is used to save the output of
  951.             the command, which can be set to include stderr or
  952.             not.  {cmd} is executed like with ":!{cmd}", any '!'
  953.             is replaced with the previous command |:!|.
  954.  
  955. These commands insert the contents of a file, or the output of a command,
  956. into the buffer.  They can be undone.  They cannot be repeated with the "."
  957. command.  They work on a line basis, insertion starts below the line in which
  958. the cursor is, or below the specified line.  To insert text above the first
  959. line use the command ":0r {name}".
  960.  
  961. After the ":read" command, the cursor is left on the first non-blank in the
  962. first new line.  Unless in Ex mode, then the cursor is left on the last new
  963. line (sorry, this is Vi compatible).
  964.  
  965. If a file name is given with ":r", it becomes the alternate file.  This can be
  966. used, for example, when you want to edit that file instead: ":e! #".  This can
  967. be switched off by removing the 'a' flag from the 'cpoptions' option.
  968.  
  969.                             *file-read*
  970. The 'fileformat' option sets the <EOL> style for a file:
  971. 'fileformat'    characters       name                ~
  972.   "dos"        <CR><NL> or <NL>   DOS format
  973.   "unix"    <NL>           Unix format
  974.   "mac"        <CR>           Mac format
  975. Previously 'textmode' was used.  It is obsolete now.
  976.  
  977. If 'fileformat' is "dos", a <CR> in front of an <NL> is ignored and a CTRL-Z
  978. at the end of the file is ignored.
  979.  
  980. If 'fileformat' is "mac", a <NL> in the file is internally represented by a
  981. <CR>.  This is to avoid confusion with a <NL> which is used to represent a
  982. <NUL>.  See |CR-used-for-NL|.
  983.  
  984. If the 'fileformats' option is not empty Vim tries to recognize the type of
  985. <EOL> (see |file-formats|).  However, the 'fileformat' option will not be
  986. changed, the detected format is only used while reading the file.
  987.  
  988. On non-MS-DOS, Win32, and OS/2 systems the message "[dos format]" is shown if
  989. a file is read in DOS format, to remind you that something unusual is done.
  990. On Macintosh, MS-DOS, Win32, and OS/2 the message "[unix format]" is shown if
  991. a file is read in Unix format.
  992. On non-Macintosh systems, the message "[Mac format]" is shown if a file is
  993. read in Mac format.
  994.  
  995. An example on how to use ":r !": >
  996.     :r !uuencode binfile binfile
  997. This command reads "binfile", uuencodes it and reads it into the current
  998. buffer.  Useful when you are editing e-mail and want to include a binary
  999. file.
  1000.  
  1001.                             *read-messages*
  1002. When reading a file Vim will display a message with information about the read
  1003. file.  In the table is an explanation for some of the items.  The others are
  1004. self explanatory.  Using the long or the short version depends on the
  1005. 'shortmess' option.
  1006.  
  1007.     long        short        meaning ~
  1008.     [readonly]    {RO}        the file is write protected
  1009.     [fifo/socket]            using a stream
  1010.     [fifo]                using a fifo stream
  1011.     [socket]            using a socket stream
  1012.     [CR missing]            reading with "dos" 'fileformat' and a
  1013.                     NL without a preceding CR was found.
  1014.     [NL found]            reading with "mac" 'fileformat' and a
  1015.                     NL was found (could be "unix" format)
  1016.     [long lines split]        at least one line was split in two
  1017.     [NOT converted]            conversion from 'fileencoding' to
  1018.                     'encoding' was desired but not
  1019.                     possible
  1020.     [converted]            conversion from 'fileencoding' to
  1021.                     'encoding' done
  1022.     [crypted]            file was decrypted
  1023.     [READ ERRORS]            not all of the file could be read
  1024.  
  1025.  
  1026.  vim:tw=78:ts=8:ft=help:norl:
  1027.